package edu.spbsu.nonsm00th.util;

import java.text.MessageFormat;

/**
 *
 * @author mbuzdov
 */
public class Precondition {

    private Precondition() {
    }

    public static void check(boolean expression, String message) {
        if (!expression) {
            throw new IllegalStateException(message);
        }
    }

    public static void notNull(Object object, String name) {
        if(null == object) {
            String message = MessageFormat.format("{0} can not be null.", name);
            throw new IllegalArgumentException(message);
        }
    }

    public static void argsNotNull(Object ... args) {
        for (Object obj : args) {
            if (null == obj) {
                throw new IllegalArgumentException("Arguments can not be null");
            }
        }
    }

}
